<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>CNCS饰品分析系统 - 数据管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 图标字体 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@6.0.0/css/all.css">
    <!-- 自定义CSS -->
    <link rel="stylesheet" href="/css/styles3.css">

</head>
<body>

<c:if test="${param.status == 'success'}">
    <div class="alert alert-success">插入数据成功！</div>
</c:if>

<c:if test="${param.status == 'exists'}">
    <div class="alert alert-warning">该饰品已存在，请勿重复插入。</div>
</c:if>

<c:if test="${param.status == 'error'}">
    <div class="alert alert-danger">插入数据失败，请检查输入内容或重试。</div>
</c:if>

<div class="container">
    <header class="header">
        <h1>CNCS饰品分析系统 - 数据管理</h1>
        <p>选择数据类型并插入新的市场数据</p>
    </header>

    <nav class="nav">
        <ul>
            <li><a href="AdminHomepage.jsp">首页</a></li>
            <li><a href="Admintransaction.jsp" class="active">成交榜</a></li>
            <li><a href="Adminrental.jsp">成租榜</a></li>
            <li><a href="Adminincrease.jsp">涨幅榜</a></li>
            <li><a href="Admindecrease.jsp">跌幅榜</a></li>
            <li><a href="Manage.jsp" class="active">管理功能</a></li>
        </ul>
    </nav>

    <div class="page-header">
        <h2>选择要插入的数据类型</h2>
        <p>从下拉菜单中选择需要插入的数据类型，然后填写相关信息。</p>
    </div>

    <div class="filter-bar">
        <div class="filter-group">
            <label for="tableSelect">选择数据类型:</label>
            <select id="tableSelect" onchange="showForm()">
                <option value="">--请选择--</option>
                <option value="increase">涨幅榜</option>
                <option value="decrease">跌幅榜</option>
                <option value="rental">成租榜</option>
                <option value="transaction">成交榜</option>
            </select>
        </div>
    </div>

    <!-- 涨幅榜 -->
    <div class="form-section" id="increaseForm" style="display:none;">
        <h2>插入涨幅榜数据</h2>
        <form action="/Manage" method="post">
            <input type="hidden" name="action" value="insertIncrease">
            <label for="increaseName">名称:</label>
            <input type="text" id="increaseName" name="name" required><br>
            <small>请输入饰品全名</small><br>
            <label for="increasePrice">价格:</label>
            <input type="number" step="0.01" id="increasePrice" name="price" required><br>
            <label for="increaseAmount">涨幅金额:</label>
            <input type="number" step="0.01" id="increaseAmount" name="increaseAmount" required><br>
            <label for="increasePercentage">涨幅百分比:</label>
            <input type="number" step="0.01" id="increasePercentage" name="increasePercentage" required><br>
            <label for="increaseDate">日期:</label>
            <input type="date" id="increaseDate" name="date" required><br>
            <button type="submit">提交</button>
        </form>
    </div>

    <!-- 跌幅榜 -->
    <div class="form-section" id="decreaseForm" style="display:none;">
        <h2>插入跌幅榜数据</h2>
        <form action="/Manage" method="post">
            <input type="hidden" name="action" value="insertDecrease">
            <label for="decreaseName">名称:</label>
            <input type="text" id="decreaseName" name="name" required><br>
            <small>请输入饰品全名</small><br>
            <label for="decreasePrice">价格:</label>
            <input type="number" step="0.01" id="decreasePrice" name="price" required><br>
            <label for="decreaseAmount">跌幅金额:</label>
            <input type="number" step="0.01" id="decreaseAmount" name="decreaseAmount" required><br>
            <label for="decreasePercentage">跌幅百分比:</label>
            <input type="number" step="0.01" id="decreasePercentage" name="decreasePercentage" required><br>
            <label for="decreaseDate">日期:</label>
            <input type="date" id="decreaseDate" name="date" required><br>
            <button type="submit">提交</button>
        </form>
    </div>

    <!-- 成租榜 -->
    <div class="form-section" id="rentalForm" style="display:none;">
        <h2>插入成租榜数据</h2>
        <form action="/Manage" method="post">
            <input type="hidden" name="action" value="insertRental">
            <label for="rentalName">名称:</label>
            <input type="text" id="rentalName" name="name" required><br>
            <small>请输入饰品全名</small><br>
            <label for="rentalPrice">价格:</label>
            <input type="number" step="0.01" id="rentalPrice" name="price" required><br>
            <label for="rentalVolume">成交量:</label>
            <input type="number" id="rentalVolume" name="volume" required><br>
            <label for="rentalDate">日期:</label>
            <input type="date" id="rentalDate" name="date" required><br>
            <button type="submit">提交</button>
        </form>
    </div>

    <!-- 成交榜 -->
    <div class="form-section" id="transactionForm" style="display:none;">
        <h2>插入成交榜数据</h2>
        <form action="/Manage" method="post">
            <input type="hidden" name="action" value="insertTransaction">
            <label for="transactionName">名称:</label>
            <input type="text" id="transactionName" name="name" required><br>
            <small>请输入饰品全名</small><br>
            <label for="transactionPrice">价格:</label>
            <input type="number" step="0.01" id="transactionPrice" name="price" required><br>
            <label for="transactionVolume">成交量:</label>
            <input type="number" id="transactionVolume" name="volume" required><br>
            <label for="transactionDate">日期:</label>
            <input type="date" id="transactionDate" name="date" required><br>
            <button type="submit">提交</button>
        </form>
    </div>

    <footer class="footer">
        <p>&copy; 2025 CNCS饰品分析系统. 保留所有权利.</p>
    </footer>
</div>

<script>
    function showForm() {
        var selected = document.getElementById("tableSelect").value;
        var forms = document.getElementsByClassName("form-section");
        for (var i = 0; i < forms.length; i++) {
            forms[i].style.opacity = "0";
            forms[i].style.display = "none";
        }
        if (selected) {
            var target = document.getElementById(selected + "Form");
            target.style.display = "block";
            setTimeout(() => {
                target.style.opacity = "1";
            }, 10);
        }
    }
</script>

</body>
</html>

